package initialize

import (
	"github.com/gin-gonic/gin"
	middleware "mxshop-api/order-web/middleware"
	"mxshop-api/order-web/router"
	"net/http"
)

func Routers() *gin.Engine {
	Router := gin.Default()
	Router.Use(middleware.Cors()) //全局跨域配置
	Router.GET("/health", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{
			"code":    http.StatusOK,
			"success": true,
		})
	})
	baseRouter := Router.Group("/o/v1")
	baseRouter.Use(middleware.Trace())
	router.InitOrderRouter(baseRouter)
	router.InitShopCartRouter(baseRouter)
	return Router
}
